package com.easygem.system.converter;

import com.easygem.common.model.system.DeptClient;
import com.easygem.common.vo.system.DeptNodeVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 文晓平
 * @Date 2024/12/7 17:22
 * @Version 1.0
 **/
public class DeptConverter {

    /**
     * 转成DeptVO(只包含部门)List
     * @param deptClients
     * @return
     */
    public static List<DeptNodeVO> converterToDeptNodeVO(List<DeptClient> deptClients){
        //先过滤出用户的部门
        List<DeptNodeVO> departmentVOS=new ArrayList<>();
        if(!CollectionUtils.isEmpty(deptClients)){
            for (DeptClient deptClient : deptClients) {
                DeptNodeVO departmentVO = new DeptNodeVO();
                    BeanUtils.copyProperties(deptClient,departmentVO);
                departmentVOS.add(departmentVO);
            }
        }
        return departmentVOS;
    }


    /**
     * 转成DeptVO
     * @param deptClients
     * @return
     */
    public static List<DeptNodeVO> converterToALLDeptNodeVO(List<DeptClient> deptClients){
        //先过滤出用户的菜单
        List<DeptNodeVO> departmentVOS=new ArrayList<>();
        if(!CollectionUtils.isEmpty(deptClients)){
            for (DeptClient deptClient : deptClients) {
                DeptNodeVO departmentVO = new DeptNodeVO();
                BeanUtils.copyProperties(deptClient,departmentVO);
                departmentVOS.add(departmentVO);
            }
        }
        return departmentVOS;
    }
    /**
     * 转成DeptVO
     * @param deptClient
     * @return
     */
    public static DeptNodeVO converterToMenuVO(DeptClient deptClient){
        DeptNodeVO departmentVO = new DeptNodeVO();
        if(deptClient !=null){
            BeanUtils.copyProperties(deptClient,departmentVO);
        }
        return departmentVO;
    }

}
